package dao

import "WORKSPACE/models"

func GetAllbill() (error, []models.Bill, int64) {
	var billData []models.Bill
	//page := consumerParam["page"].(int)
	//pageSize := consumerParam["limit"].(int)
	//searchName := consumerParam["searchName"].(string)
	var total int64
	err := db.Table("bill").Order("bill_id ASC").Count(&total).Find(&billData).Error
	return err, billData, total
}

func AddBill(bill models.Bill) error {
	err := db.Table("bill").Create(&bill).Error
	return err
}

func UpdateBill(bill models.Bill) error {
	err := db.Table("bill").Where("bill_id= ?", bill.Bill_id).Updates(&bill).Error
	return err
}

func Delbill(id int) error {
	err := db.Table("bill").Where("bill_id = ?", id).Delete(models.Bill{}).Error
	return err
}
